package trying.ExceptionTest;

import java.io.IOException;

public class Test {
    /**
     * checkedException调用时必须声明或捕获
     * RuntimeException调用时可不做处理
     * 调用者使用try包裹没用
     * @param args
     */
    public static void main(String[] args) {
        test4();
    }

    //没用，调用代码直接报出异常，调用者try包裹没用
    public static void test1() {
        try {
            Exceptions excp = new Exceptions();
            excp.ExcpIO();
        } catch (IOException e) {
            System.out.println("err");
        }
    }

    //直接声明
    public static void test2() throws IOException {
        Exceptions excp = new Exceptions();
        excp.ExcpIO();
    }

    //运行时异常，调用者不用做处理
    public static void test3() {
        Exceptions excp = new Exceptions();
        excp.ExcpNull();
    }

    //调用方法try
    public static void test4() {
        Exceptions excp = new Exceptions();
        excp.ExcpIO2();
    }
}
